package td2;

public class Note implements Comparable<Note> {

	private Matiere matiere;
	private double valeur;
	private Etudiant etudiant;
	
	
	
	public Note(Matiere matiere, double valeur, Etudiant etudiant) {
		this.matiere = matiere;
		this.valeur = valeur;
		this.etudiant = etudiant;
	}
	
	
	public Matiere getMatiere() {
		return matiere;
	}
	public void setMatiere(Matiere matiere) {
		this.matiere = matiere;
	}
	public double getValeur() {
		return valeur;
	}
	public void setValeur(double valeur) {
		this.valeur = valeur;
	}
	public Etudiant getEtudiant() {
		return etudiant;
	}
	public void setEtudiant(Etudiant etudiant) {
		this.etudiant = etudiant;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(valeur);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Note other = (Note) obj;
		if (Double.doubleToLongBits(valeur) != Double
				.doubleToLongBits(other.valeur))
			return false;
		return true;
	}


	@Override
	/**
	 * compareTo compare 2 notes
	 */
	public int compareTo(Note e) {
		if(e.valeur == this.valeur)
			return 0;
		if(e.valeur > this.valeur)
			return 1;
		else
			return -1;
	}


	@Override
	public String toString() {
		return "Note [matiere=" + matiere + ", valeur=" + valeur
				+ ", etudiant=" + etudiant + "]";
	}
	
	
	
	
	
	
}
